package org.spring.springboot.app.adv.advinfo.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.springboot.app.adv.advinfo.dao.AdvInfoDao;
import org.spring.springboot.app.adv.advinfo.domain.po.AdvInfoPO;
import org.spring.springboot.app.adv.advinfo.domain.vo.AdvInfoCountVO;
import org.spring.springboot.app.adv.advinfo.domain.vo.AdvInfoVO;
import org.spring.springboot.app.adv.advinfo.service.IAdvInfoService;
import org.spring.springboot.app.hard.hardlog.domain.po.HardLogPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdvInfoServiceImpl implements IAdvInfoService {

    private static final Logger LOGGER = LoggerFactory.getLogger(AdvInfoServiceImpl.class);

    @Autowired
    private AdvInfoDao advinfoDao;


    @Override
    public AdvInfoPO find(String id) {
        return advinfoDao.selectByPrimaryKey(id);
    }

    @Override
    public int save(AdvInfoPO po) {
        po.preInsert();
        return advinfoDao.insertSelective(po);
    }

    @Override
    public int update(AdvInfoPO po) {
        po.preUpdate();
        return advinfoDao.updateByPrimaryKeySelective(po);
    }

    @Override
    public int delete(String id) {
        AdvInfoPO po = new AdvInfoPO();
        po.setId(id);
        po.preDelete();
        return advinfoDao.updateByPrimaryKeySelective(po);
    }

    @Override
    public int deletes(String ids) {
        AdvInfoPO record = new AdvInfoPO();
        String[] id_s = ids.split(",");
        record.preDelete();
        int count = 0;
        for (String id : id_s) {
            record.setId(id);
            count += advinfoDao.updateByPrimaryKeySelective(record);
        }
        return count;
    }

    @Override
    public List<AdvInfoVO> findGraphical(String officeId) {
        return advinfoDao.findGraphical(officeId);
    }

    @Override
    public List<AdvInfoCountVO> findCount(String officeId) {
        return advinfoDao.findCount(officeId);
    }
}
